import OceanComponent from './OceanComponent';
import ORadio from '../../components/Radio.vue';
import { RadioProps, OptionProps } from '../common/props';

class Radio extends OceanComponent<RadioProps> {
  isOceanComponent = false;
  constructor(attrs?: RadioProps) {
    super(ORadio, attrs, {
      value: '',
      options: [],
      cols: 8,
      'on-update:value': v => (this.attrs.value = v)
    });
  }
  option(label: string, value: OptionProps['value'], disabled: boolean = false) {
    let option: OptionProps = { label, value, disabled };
    this.attrs.options.push(option);
    return option;
  }
  setValue(value: OptionProps['value']) {
    this.attrs.value = value;
  }
  get value() {
    return this.attrs.value;
  }

  set value(v) {
    this.attrs.value = v;
  }
}

export default Radio;
